using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace tecmosuperbowlmanager
{
    public class writeRom
    {
        private string _fileName;
        private string FileName
        {
            get { return _fileName; }
            set { _fileName = value; }
        }

        private List<byte> _bytesOfFile;
        private List<byte> BytesOfFile
        {
            get { return _bytesOfFile; }
            set
            {
                //make this throw noBytesException (in the Exceptions file that needs to be created)
                if (value == null) { throw new NullReferenceException("Empty rom was passed..."); }
                else { _bytesOfFile = value; }
            }
        }

        /// <summary>
        /// this will write the output file based on the give output pathname and the list of bytes to write
        /// </summary>
        /// <param name="pathNameOfFile"></param>
        /// <param name="bytesToWrite"></param>
        public writeRom(string pathNameOfFile)
        {
            FileName = pathNameOfFile;
        }

        public void writeFile(List<byte> bytesToWrite)
        {
            FileStream fs = new FileStream(FileName, FileMode.Create);
            BinaryWriter writer = new BinaryWriter(fs);
            BytesOfFile = bytesToWrite;
            foreach (byte writeByte in BytesOfFile)
            {
                writer.Write(writeByte);
            }
            writer.Close();
            fs.Close();
        }
    }
}
